package com.peaksport.framework.base.venum;

import javax.persistence.AttributeConverter;
import javax.persistence.Converter;

/**
 * 
 * 状态枚举(字符串)转换类
 * 
 * @author jinbin_guo  2019年4月16日 下午4:40:52
 *
 */
@Converter
public class BaseStringConverter implements AttributeConverter<BaseStringEnum,String> {

    @Override
    public String convertToDatabaseColumn(BaseStringEnum attribute) {
    	if (attribute == null) return null;
        return attribute.getValue();
    }

    @Override
    public BaseStringEnum convertToEntityAttribute(String dbData) {
        return new BaseStringEnum(dbData);
    }
}
